const sequelize = require('../config/connect.js')//引入数据库连接文件
const config = require('../config/config.js')//引入数据库配置文件
const { Op, Model, DataTypes } = require('sequelize')//引入nodejs的orm模型文件
const vipLevel = require('./vipLevel.js')//引入vip等级表信息
class customer extends Model{}  //顾客信息表 


customer.init({
    customerIdCard:{
        type:DataTypes.STRING(18),
        primaryKey:true,
        comment:'顾客身份证'
    },
    customerName:{
        type:DataTypes.STRING(16),
        allowNull:false
    },
    customerSex:{
        type:DataTypes.STRING(4),
        allowNull:false,
        comment:'性别'
    },
    customerBirthday:{
        type:DataTypes.DATE,
        allowNull:true,
        comment:'出生日期'
    },
    customerVipLevel:{
        type:DataTypes.SMALLINT,
        allowNull:true,
        references:{
            model:vipLevel,
            key:'level'
        },
        comment:'会员等级'
    },
    customerPhoneNumber:{
        type:DataTypes.STRING(11),
        allowNull:false,
        comment:'手机号码'
    },
    totalAmount:{
        type:DataTypes.INTEGER,
        defaultValue:0,
        comment:'消费金额'
    },
    remarks:{
        type:DataTypes.STRING(32),
        allowNull:true,
        comment:'备注'
    }
},{
    sequelize,
    charset:config.charset,
    timestamps:false,
    freezeTableName:true,
    modelName:'customer'
})

module.exports = customer;